<template>
  <div class="inner">
    <h3>传感器状况统计</h3>
    <div class="chart">
      <!-- 图表准备 -->
      <div class="pie">
        <!-- <ChartLine ref="chart_line_one"/>   -->
        <NodeChart ref="chart_pie"/>
      </div>
    </div>
  </div>
</template>

<script>
import NodeChart from "../echart/pointchart.vue"
import { mapState } from "vuex";

export default {
  data(){
    return{
      data1:0,
      data2:0,
      data3:0,
    }
  },
  // vuex数据引入
  computed: {
    ...mapState([
      // sensorvalue
      "SVdata"
    ]),
  },
  
  components:{
    NodeChart
  },
  methods:{
    changedata(){
      this.data1 = this.data2 = this.data3 = 0
      // console.log(this.SVdata);
      for(var i=0;i < this.SVdata.length;i++){
        if(this.SVdata[i].timetype == '健康'){
          this.data1++
          
        }else if (this.SVdata[i].timetype == '良好'){
          this.data2++
        }else {
          this.data3++
        }
      }
      // console.log('统计数据',this.data1);
      this.$refs.chart_pie.charts(this.data1,this.data2,this.data3)
    }
  },
  mounted(){
    this.changedata()
  }
}
</script>

<style>
</style>